package com.learnpilot.datechange.service.impl;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.learnpilot.datechange.service.CommandExecutor;
import com.learnpilot.datechange.service.DateChanger;

public class DateChangerImpl implements DateChanger {

	private final Logger LOG = LoggerFactory.getLogger(DateChangerImpl.class);
	private CommandExecutor commandExecutor;

	@Override
	public void changeSystemDate(String date) {
		String[] command = new String[3];
		command[0] = "cmd";
		command[1] = "/c"; // "/C" command Executes the specified command and returns.
		command[2] = "date "+date;
		getCommandExecutor().runCommand(command);
		LOG.debug("Inside DateChangerImpl.changeSystemDate(). Command executed : "+command[2] );
	}

	public CommandExecutor getCommandExecutor() {
		return commandExecutor;
	}

	public void setCommandExecutor(CommandExecutor commandExecutor) {
		this.commandExecutor = commandExecutor;
	}

}
